package 华为机试;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class HJ2_计算某字符出现次数 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine().toLowerCase();
        String ch = scan.nextLine();
        char res = ch.toLowerCase().charAt(0);
        int count = 0;
        for(int i = 0; i < str.length(); i++) {
            if(res == str.charAt(i)) {
                count++;
            }
        }
        System.out.println(count);
    }
}
